﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "IFamilyEntity.h"
#include "IGraphicsNodeReference.h"
#include "GmFamilyService.h"

namespace gfam
{
    /// \brief 草图线类型
    enum class FamilySketchLineType : int32_t
    {
        Normal = 0,    ///< 草图线
        Axis,          ///< 旋转体轴线
        Reference,     ///< 草图内参照线
        Location,       ///< 底部或顶部定位线
        ChamferPoint    ///< 倒斜角辅助点
    };


    /// \brief 草图线的接口类
    class GM_FAMILY_SERVICE_EXPORT IFamilySketchCurve : public IFamilyEntity
    {
        DEFINE_CAST_DERIVED(gfam::IFamilySketchCurve, gfam::IFamilyEntity)
    public:

        //virtual std::wstring GetName() const = 0;
        //virtual bool SetName(std::wstring& name) = 0;

        /// \brief  获取草图id
        ///
        /// \return   草图id
        virtual gcmp::ElementId GetSketchId() const = 0;

        /// \brief  设置草图id
        ///
        /// \param   sketchId 草图id
        virtual void SetSketchId(const gcmp::ElementId& sketchId) = 0;

        /// \brief  设置草图线类型
        ///
        /// \return 草图线类型
        virtual FamilySketchLineType GetSketchLineType() const = 0;

        /// \brief  设置草图线类型
        ///
        /// \param   sketchLineType 草图线类型
        virtual void SetSketchLineType(FamilySketchLineType sketchLineType) = 0;

        /// \brief  获取夹点
        ///
        /// \param   arrGripPoints 保存夹点
        virtual void GetGripPoints(std::vector<gcmp::Vector3d>&arrGripPoints)const = 0;

        /// \brief  获取起点
        ///
        /// \return   起点
        virtual gcmp::Vector3d GetStartPoint() const = 0;

        /// \brief  获取末点
        ///
        /// \return   末点
        virtual gcmp::Vector3d GetEndPoint() const = 0;

        /// \brief  获取端点（起点、末点等等）
        ///
        /// \param index 下标索引（从0开始）
        /// \return 端点
        virtual gcmp::Vector3d GetExtremePoint(int index) const = 0;

        /// \brief  获取中点
        ///
        /// \return   中点
        virtual gcmp::Vector3d GetMiddlePoint() const = 0;

        /// \brief  获取参数param对应的点
        ///
        /// \param 参数
        /// \return   参数对应的点
        virtual gcmp::Vector3d GetPoint(double param) const = 0;

        /// \brief  获取参数param对应的切向
        ///
        /// \return   切向
        virtual gcmp::Vector3d GetTangentAt(double param) const = 0;

        /// \brief  获取曲线最近点
        ///
        /// \param givenPoint 给定的点坐标
        /// \param pointOnCurve  保存最近点
        /// \return   成功返回true,否则返回false
        virtual bool GetClosestPointTo(const gcmp::Vector3d &givenPoint, gcmp::Vector3d &pointOnCurve) const = 0;


        /// \brief  获取起点参数
        ///
        /// \return   起点参数
        virtual double GetStartLimit() const = 0;

        /// \brief  获取末点参数
        ///
        /// \return   末点参数
        virtual double GetEndLimit() const = 0;

        /// \brief  获取曲线图形节点
        ///
        /// \return   曲线图形节点
        virtual gcmp::IGraphicsCurve3d* GetGCurveFW() = 0;

        /// \brief  获取曲线图形节点
        ///
        /// \return   曲线图形节点
        virtual const gcmp::IGraphicsCurve3d* GetGCurve() const = 0;

        /// \brief  设置曲线图形节点
        ///
        /// \param   inputCurve 曲线图形节点
        virtual void SetGCurve(gcmp::OwnerPtr<gcmp::IGraphicsCurve3d> inputCurve) = 0;

        /// \brief  获取是否是二维曲线
        ///
        /// \return  如果是二维曲线就返回true,否则返回false
        virtual bool Is2DCurve() const = 0;

        /// \brief  获取约束解算曲线
        ///
        /// \return  约束解算曲线
        virtual const gcmp::IGraphicsCurve3d* GetGCurveForSolver() const = 0;

        /// \brief  获取约束解算曲线
        ///
        /// \return  约束解算曲线
        virtual gcmp::IGraphicsCurve3d* GetGCurveForSolverFW() = 0;

        /// \brief  设置约束解算曲线
        ///
        /// \param  pCurve 约束解算曲线
        virtual void SetGCurveForSolve(const gcmp::IGraphicsCurve3d *pCurve) = 0;

        /// \brief  获取曲线在草图中的索引
        ///
        /// \return  草图中的索引
        virtual int GetIndexInSketch() const = 0;

        /// \brief  设置曲线在草图中的索引
        ///
        /// \param index 索引
        virtual void SetIndexInSketch(int index) = 0;

        /// \brief 获取ImplementationUid
        /// 
        /// \return ImplementationUid
        static gcmp::UniIdentity GetImplementationUid();

        /// \brief 设置主对象的Id
        /// 主对象指具有强依赖关系的对象，当主对象被删除时，从对象也会被删除。
        ///
        /// \param masterId 主对象Id
        /// \return void
        virtual void SetMasterId(gcmp::ElementId masterId) = 0;

    };
}